package net.orange.architecture.db;

import java.util.Collection;

import net.orange.architecture.model.BaseValueObject;

/**
 * The interface of base database access object ,include some standard database
 * operations (list / find / new / delete / update / ......).
 */
public interface IObjectManager {
	/**
	 * @return Returns the valueObjectClassName.
	 */
	public String getValueObjectClassName();

	/**
	 * @param valueObjectClassName
	 *            The valueObjectClassName to set.
	 */
	public void setValueObjectClassName(String valueObjectClassName)
			throws Exception;

	/**
	 * Retrieves the value object collection according to conditions.
	 * 
	 * @param cds
	 *            The conditions
	 * @return The value object collection.
	 * @throws Exception
	 */
	public Collection list(Conditions cds) throws Exception;

	/**
	 * Retrieves the value object collection according to conditions and orders.
	 * 
	 * @param cds
	 *            The conditions
	 * @param orders
	 *            The orders.
	 * @return The value object collection.
	 * @throws Exception
	 */
	public Collection list(Conditions cds, Orders orders) throws Exception;

	/**
	 * Retrieves the value object collection according to list conditions.
	 * 
	 * @param cds
	 *            cds The conditions
	 * @return The value object collection.
	 * @throws Exception
	 */
	public Collection list2(ListConditions cds) throws Exception;

	/**
	 * Retrieves the value object collection according to the SQL statement.
	 * 
	 * @param s
	 *            The SQL statement.
	 * @return The value object collection.
	 * @throws Exception
	 */
	public Collection list(String s) throws Exception;

	/**
	 * Retrieves the value object according to the object id.
	 * 
	 * @param id
	 *            The object id.
	 * @return The value object.
	 * @throws Exception
	 */
	public BaseValueObject find(long id) throws Exception;

	/**
	 * Retrieves the value object according to the object code.
	 * 
	 * @param field
	 *            The value object field name.
	 * @param value
	 *            The value object code.
	 * @return The value object.
	 * @throws Exception
	 */
	public BaseValueObject find(String field, String code) throws Exception;

	/**
	 * Retrieves the value object according the conditions.
	 * 
	 * @param cds
	 *            The conditions
	 * @return The value object.
	 * @throws Exception
	 */
	public BaseValueObject find(Conditions cds) throws Exception;

	/**
	 * Create the persistency value object in database.
	 * 
	 * @param b0
	 *            The value Object.
	 * @return Whether success.
	 * @throws Exception
	 */
	public boolean create(BaseValueObject b0) throws Exception;

	/**
	 * Update the persistency value object in database.
	 * 
	 * @param b0
	 *            The value Object.
	 * @return Whether success.
	 * @throws Exception
	 */
	public boolean update(BaseValueObject b0) throws Exception;

	/**
	 * Create(Update) the persistency value object in database.
	 * 
	 * @param b0
	 *            The value Object.
	 * @return Whether success.
	 * @throws Exception
	 */
	public boolean createOrUpdate(BaseValueObject b0) throws Exception;

	/**
	 * Remove the persistency value object in database.
	 * 
	 * @param b0
	 *            The value Object.
	 * @return Whether success.
	 * @throws Exception
	 */
	public boolean delete(BaseValueObject b0) throws Exception;

	/**
	 * Remove the persistency value object in database according the object id.
	 * 
	 * @param id
	 *            The object id
	 * @return Whether success.
	 * @throws Exception
	 */
	public boolean delete(long id) throws Exception;

	/**
	 * Update the object by batch
	 * 
	 * @param s
	 * @return the record updated
	 * @throws Exception
	 */
	public int batchUpdate(String s) throws Exception;
}